package com.tz.hotelmanager.Utils;

import javax.servlet.http.HttpSession;

import com.alibaba.fastjson.JSONObject;

public class PermissionCheck {
  public static Boolean checkisAdmin (HttpSession session){
    JSONObject result = new JSONObject();
    if(session.getAttribute("userbase") == null ){
      session.setAttribute("userbase", null);
      return false ;
    }
    JSONObject jsonObject= JSONObject.parseObject( (String)session.getAttribute("userbase") );
    if(jsonObject.get("type") != "1" ) {
      session.setAttribute("userbase", null);
      return false ;
    }
    if(jsonObject.get("type") == "1" ) {
       return true ;
    }
    session.setAttribute("userbase", null);
    return false;
  }
  public Boolean checkUser (HttpSession session){
    JSONObject result = new JSONObject();
    if(session.getAttribute("userbase") == null ){
      session.setAttribute("userbase", null);
      return false ;
    }
    JSONObject jsonObject= JSONObject.parseObject( (String)session.getAttribute("userbase") );
    if(jsonObject.get("type") == "2" && jsonObject.get("type") == "1"  ) {
      return true ;
    }
    session.setAttribute("userbase", null);
    return false;
  }


}